package com.ck.client.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ck.client.dao.DeviceSettingMapper;
import com.ck.common.model.DeviceSetting;
import com.ck.client.service.DeviceSettingService;

/**
 * 终端设置Service
 */
@Service(value = "deviceSettingService")
public class DeviceSettingServiceImpl implements DeviceSettingService {
	
	@Autowired
	private DeviceSettingMapper deviceSettingMapper;

	@Override
	@Transactional( rollbackFor = Exception.class)
	public boolean register(DeviceSetting deviceSetting) {
		int effect = deviceSettingMapper.saveDeviceSetting(deviceSetting);
		return effect > 0;
	}

	@Override
	public DeviceSetting getDeviceSetting(String deviceCode) {
		return deviceSettingMapper.getDeviceSetting(deviceCode);
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public boolean updateDeviceSetting(DeviceSetting deviceSetting) {
		deviceSetting.setUpdateTime(System.currentTimeMillis());
		int effect = deviceSettingMapper.updateDeviceSetting(deviceSetting);
		return effect > 0;
	}

}
